initSession_ID();// 初始化session_id
var pageShowList = ["购买流程","咖啡口味","咖啡机使用及卫生","咖啡杯子及辅料","优惠券及分享券","商品配送","人员服务质量","其他建议"];
$("#feedBackText").on("input",function () {
    var text = $("#feedBackText").val();
    if(text) {
        $("#submit").removeClass("submitBackground");
        $("#submit").removeAttr("disabled");
    } else {
        $("#submit").addClass("submitBackground");
        $("#submit").attr("disabled","disabled");
    }
})
$("#submit").on("tap",function () {
    var path = "user/feedback/add";
    var TYPE = $("#reason").val();
    var CONTENT = $("#feedBackText").val();
    var TYPE_ID = pageShowList.indexOf(TYPE) + 1;
    var params = {
        "TYPE_ID":TYPE_ID,
        "TYPE":TYPE,
        "CONTENT":CONTENT,
        "STORE_ID":STORE_ID
    }
    if(TYPE_ID < 0 || !TYPE || !CONTENT) {
        showErroMsg("请完选择反馈原因后提交！",function(){
                $(".showErrorMassage").remove();
            });
        return false;
    }
request(path,params,function (res) {
    var flg = /^0+$/ig.test(res.RSPCD); //全零true
    if(flg) {
        location.replace("./feed_back_success.html");
    }
})


})
/*
$(document).ready(function () {
    var fpath = "user/feedback/types";
    var fparams = {
        "SESSION_ID":SESSION_ID
    };
    request(fpath,fparams,function (res) {
        var showList = [];
        _.each(res.BODY.LIST,function (item, index) {
            showList.push(item.TYPE);
        })
        pageShowList = showList;
        $("#reason").picker({
            title: "原因",
            toolbarCloseText: '确定',
            cols: [
                {
                    textAlign: 'center',
                    values: showList,
                    displayValues: showList,
                }
            ]
        });
    })
});
*/

$("#reason").picker({
    title: "类别",
    toolbarCloseText: '确定',
    cols: [
        {
            textAlign: 'center',
            values: pageShowList,
            displayValues: pageShowList,
        }
    ]
});